﻿using System;
using System.Windows.Forms;

namespace AutoUpdater
{
    public enum MlableButtonType
    {
        Both,
        Mini,
        Close
    }

    public partial class MLable : UserControl
    {
        public MlableButtonType MlableButton { get; set; }
        public MLable()
        {
            InitializeComponent();
            switch (this.MlableButton)
            {
                case MlableButtonType.Mini:
                    this.lbl_Min.Enabled = true;
                    this.lbl_Min.Visible = true;
                    this.lbl_Close.Enabled = false;
                    this.lbl_Close.Visible = false;
                    break;
                case MlableButtonType.Close:
                    this.lbl_Min.Enabled = false;
                    this.lbl_Min.Visible = false;
                    this.lbl_Close.Enabled = true;
                    this.lbl_Close.Visible = true;
                    break;
                default:
                    this.lbl_Min.Enabled = true;
                    this.lbl_Min.Visible = true;
                    this.lbl_Close.Enabled = true;
                    this.lbl_Close.Visible = true;
                    break;
            }
        }

        private void MLable_Load(object sender, EventArgs e)
        {

        }
        private void lbl_MouseDown(object sender, MouseEventArgs e)
        {
            Label l = (Label)sender;
            switch (l.Name)
            {
                case "lbl_Close":
                    l.Image = Properties.Resources.btn_close_down;
                    break;
                case "lbl_Min":
                    l.Image = Properties.Resources.btn_mini_down;
                    break;
            }
        }

        private void lbl_MouseHover(object sender, EventArgs e)
        {
            Label l = (Label)sender;
            switch (l.Name)
            {
                case "lbl_Close":
                    l.Image = Properties.Resources.btn_close_highlight;
                    break;
                case "lbl_Min":
                    l.Image = Properties.Resources.btn_mini_highlight;
                    break;
            }
        }

        private void lbl_MouseUp(object sender, MouseEventArgs e)
        {

        }

        private void lbl_MouseLeave(object sender, EventArgs e)
        {
            Label l = (Label)sender;
            switch (l.Name)
            {
                case "lbl_Close":
                    l.Image = Properties.Resources.btn_close_normal;
                    break;
                case "lbl_Min":
                    l.Image = Properties.Resources.btn_mini_normal;
                    break;
            }
        }

        private void lbl_Click(object sender, EventArgs e)
        {
            Label l = (Label)sender;
            switch (l.Name)
            {
                case "lbl_Close":
                    this.Parent.FindForm().Close();
                    break;
                case "lbl_Min":
                    this.Parent.FindForm().WindowState = FormWindowState.Minimized;
                    break;
            }
        }
    }
}
